package com.collection;
import java.util.*;

//测试Collection接口中的方法

public class TestList {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>(); //ArrayList实现了List接口，然后继承了Collection接口

        c.add("王小喵");
        c.add("王大喵");
        System.out.println(c);  //[王小喵, 王大喵]
        System.out.println(c.size());   //2

        System.out.println(c.contains("王中喵"));  //没有王中喵，所以是false


        Object[] objs = c.toArray();    //将c转化成了Object[]
        System.out.println(Arrays.toString(objs));

        c.remove("王大喵");    //只是从容器中移出去了，但对象本身还在
        System.out.println(c);  //[王小喵]
        System.out.println(c.size());   //1

        c.clear();
        System.out.println(c.size());   //0

    }
}
